package com.example.ktpspringboot.controller;

import com.example.ktpspringboot.entity.Student;
import com.example.ktpspringboot.entity.Teacher;
import com.example.ktpspringboot.service.impl.RegisterServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class RegisterController {

    @Autowired
    private RegisterServiceImpl registerServiceImpl;

    @RequestMapping("/registerStudent")
    public String registerStudent(@RequestBody Student student) {
        student.setAccount(registerServiceImpl.generateAccount());
        return registerServiceImpl.judgeStuMethod(student);
    }

    @RequestMapping("/registerTeacher")
    public String register(@RequestBody Teacher teacher) {
        teacher.setAccount(registerServiceImpl.generateAccount());
        return registerServiceImpl.judgeTeaMethod(teacher);
    }
}
